package com.yy.wga.goods.service.controller;


import com.yy.wga.common.core.dto.PageBean;
import com.yy.wga.common.core.dto.Result;
import com.yy.wga.resource.feign.request.ResourceGoodsCategoryReq;
import com.yy.wga.resource.feign.response.GetAllCategoryGoodsResp;
import com.yy.wga.resource.feign.response.GetHeadSupplierGoodsResponse;
import com.yy.wga.resource.feign.response.GetPageCategoryGoodsResp;
import com.yy.wga.resource.feign.response.GetResourceGoodsCategoryResponse;
import com.yy.wga.resource.service.manage.ResourceGoodsCategoryManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 资源商品分类管理
 */
@RestController
@RequestMapping("api/resource/goods/category")
public class ResourceGoodsCategoryController implements ResourceGoodsCategoryFeign {

    @Resource
    private ResourceGoodsCategoryManager resourceGoodsCategoryManager;


    @PostMapping(value = "/addCategory")
    public Result<Void> addCategory(@RequestBody @Valid ResourceGoodsCategoryReq.AddCategory request) {
        resourceGoodsCategoryManager.addCategory(request);
        return Result.success();
    }

    @PostMapping(value = "/updateCategory")
    public Result<Void> updateCategory(@RequestBody @Valid ResourceGoodsCategoryReq.UpdateCategory request) {
        resourceGoodsCategoryManager.updateCategory(request);
        return Result.success();
    }

    @PostMapping(value = "/deleteCategory")
    public Result<Void> deleteCategory(@RequestBody @Valid ResourceGoodsCategoryReq.DeleteCategory request) {
        resourceGoodsCategoryManager.deleteCategory(request);
        return Result.success();
    }

    @GetMapping(value = "/listCategory")
    public Result<List<GetResourceGoodsCategoryResponse>> listCategory() {
        List<GetResourceGoodsCategoryResponse> list = resourceGoodsCategoryManager.listCategory();
        Result<List<GetResourceGoodsCategoryResponse>> result = Result.success();
        result.setData(list);
        return result;
    }


    @PostMapping(value = "/sortCategory")
    public Result<Void> sortCategory(@RequestBody @Valid ResourceGoodsCategoryReq.SortCategory request) {
        resourceGoodsCategoryManager.sortCategory(request);
        return Result.success();
    }

    @PostMapping(value = "/changeCategoryStatus")
    public Result<Void> changeCategoryStatus(@RequestBody @Valid ResourceGoodsCategoryReq.ChangeCategoryStatus request) {
        resourceGoodsCategoryManager.changeCategoryStatus(request);
        return Result.success();
    }

    @PostMapping(value = "/changeHomepageDisplay")
    public Result<Void> changeHomepageDisplay(@RequestBody @Valid ResourceGoodsCategoryReq.ChangeHomepageDisplay request) {
        resourceGoodsCategoryManager.changeHomepageDisplay(request);
        return Result.success();
    }

    @PostMapping(value = "/changeSupportSubsidyAmount")
    public Result<Void> changeSupportSubsidyAmount(@RequestBody @Valid ResourceGoodsCategoryReq.ChangeSupportSubsidyAmount request) {
        resourceGoodsCategoryManager.changeSupportSubsidyAmount(request);
        return Result.success();
    }



    @PostMapping(value = "/addGoods")
    public Result<Void> addGoods(@RequestBody @Valid ResourceGoodsCategoryReq.AddGoods request) {
        resourceGoodsCategoryManager.addGoods(request);
        return Result.success();
    }

    @PostMapping(value = "/deleteGoods")
    public Result<Void> deleteGoods(@RequestBody @Valid ResourceGoodsCategoryReq.DeleteGoods request) {
        resourceGoodsCategoryManager.deleteGoods(request);
        return Result.success();
    }

    @PostMapping(value = "/pageGoods")
    public Result<PageBean<GetPageCategoryGoodsResp>> pageGoods(@RequestBody @Valid ResourceGoodsCategoryReq.PageGoods request) {
        PageBean<GetPageCategoryGoodsResp> pageBean = resourceGoodsCategoryManager.pageGoods(request);
        Result<PageBean<GetPageCategoryGoodsResp>> result = Result.success();
        result.setData(pageBean);
        return result;
    }

    @PostMapping(value = "/allGoods")
    public Result<List<GetAllCategoryGoodsResp>> allCategoryGoods(@RequestBody @Valid ResourceGoodsCategoryReq.AllGoods request) {
        List<GetAllCategoryGoodsResp> respList = resourceGoodsCategoryManager.allCategoryGoods(request);
        Result<List<GetAllCategoryGoodsResp>> result = Result.success();
        result.setData(respList);
        return result;
    }


    @PostMapping(value = "/sortGoods")
    public Result<Void> sortGoods(@RequestBody @Valid ResourceGoodsCategoryReq.SortGoods request) {
        resourceGoodsCategoryManager.sortGoods(request);
        return Result.success();
    }

    @PostMapping(value = "/setRecommendReason")
    public Result<Void> setRecommendReason(@RequestBody @Valid ResourceGoodsCategoryReq.SetRecommendReason request) {
        resourceGoodsCategoryManager.setRecommendReason(request);
        return Result.success();
    }

    @PostMapping(value = "/setSubsidyAmount")
    public Result<Void> setSubsidyAmount(@RequestBody @Valid ResourceGoodsCategoryReq.SetSubsidyAmount request) {
        resourceGoodsCategoryManager.setSubsidyAmount(request);
        return Result.success();
    }

    @PostMapping(value = "/getHeadSupplierGoods")
    public Result<GetHeadSupplierGoodsResponse> getHeadSupplierGoods(@RequestBody @Valid ResourceGoodsCategoryReq.GetHeadSupplierGoodsReq request) {
        GetHeadSupplierGoodsResponse response = resourceGoodsCategoryManager.getHeadSupplierGoods(request);
        Result<GetHeadSupplierGoodsResponse> result = Result.success();
        result.setData(response);
        return result;
    }

    @PostMapping(value = "/getHeadSupplierGoodsV2")
    public Result<PageBean<GoodsInfoResp>> getHeadSupplierGoodsV2(@RequestBody @Valid ResourceGoodsCategoryReq.GetHeadSupplierGoodsReqV2 request) {
        PageBean<GoodsInfoResp> headSupplierGoodsV2 = resourceGoodsCategoryManager.getHeadSupplierGoodsV2(request);
        return Result.success(headSupplierGoodsV2);
    }

}
